{**
 * Pharmacy edit
 *
 * @package   OpenEMR
 * @link      http://www.open-emr.org
 * @author    Brady Miller <brady.g.miller@gmail.com>
 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
 * @license   https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
 *}
<form name="pharmacy" method="post" action="{$FORM_ACTION}"  class='form-horizontal' onsubmit="return top.restoreSession()">
<!-- it is important that the hidden form_id field be listed first, when it is called is populates any old information attached with the id, this allows for partial edits
        if it were called last, the settings from the form would be overwritten with the old information-->
    <input type="hidden" name="form_id" value="{$pharmacy->id|escape:'html'}" />
    <div class="form-group">
        <label for="name" class="control-label col-sm-2">{xl t='Name'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="name" name="name" class="form-control" aria-describedby="nameHelpBox" value="{$pharmacy->name|escape:'html'}" onKeyDown="PreventIt(event)">
            <span id="nameHelpBox" class="help-block">({xl t='Required'|escape:'html'})</span>
        </div>
    </div>
    <div class="form-group">
        <label for="address_line1" class="control-label col-sm-2">{xl t='Address'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="address_line1" name="address_line1" class="form-control" value="{$pharmacy->address->line1|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    <div class="form-group">
        <label for="address_line2" class="control-label col-sm-2">{xl t='Address'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="address_line2" name="address_line2" class="form-control" value="{$pharmacy->address->line2|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    <div class="form-group">
        <label for="city" class="control-label col-sm-2">{xl t='City'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="city" name="city" class="form-control" value="{$pharmacy->address->city|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    <div class="form-group">
        <label for="state" class="control-label col-sm-2">{xl t='State'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" maxlength="2" id="state" name="state" class="form-control" value="{$pharmacy->address->state|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    <div class="form-group">
        <label for="city" class="control-label col-sm-2">{xl t='Zip Code'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="zip" name="zip" class="form-control" value="{$pharmacy->address->zip|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    <div class="form-group">
        <label for="email" class="control-label col-sm-2">{xl t='Email'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="email" name="email" class="form-control" value="{$pharmacy->email|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    <div class="form-group">
        <label for="phone" class="control-label col-sm-2">{xl t='Phone'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="phone" name="phone" class="form-control" value="{$pharmacy->get_phone()|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    <div class="form-group">
        <label for="fax" class="control-label col-sm-2">{xl t='Fax'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="fax" name="fax" class="form-control" value="{$pharmacy->get_fax()|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    <div class="form-group">
        <label for="npi" class="control-label col-sm-2">{xl t='NPI'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="npi" name="npi" class="form-control" value="{$pharmacy->get_npi()|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    <div class="form-group">
        <label for="ncpdp" class="control-label col-sm-2">{xl t='NCPDP'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="ncpdp" name="ncpdp" class="form-control" value="{$pharmacy->get_ncpdp()|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    <div class="form-group">
        <label for="transmit_method" class="control-label col-sm-2">{xl t='Default Method'|escape:'html'}</label>
        <div class="col-sm-8">
            <select id="transmit_method" name="transmit_method" class="form-control">
                {html_options options=$pharmacy->transmit_method_array selected=$pharmacy->transmit_method}
            </select>
        </div>
    </div>
    <div class="btn-group col-sm-offset-2">
        <a href="javascript:submit_pharmacy();" class="btn btn-default btn-save" onclick="top.restoreSession()">
            {xl t='Save'|escape:'html'}
        </a>
        <a href="controller.php?practice_settings&pharmacy&action=list" class="btn btn-link btn-cancel" onclick="top.restoreSession()">
            {xl t='Cancel'|escape:'html'}
        </a>
    </div>
    <input type="hidden" name="id" value="{$pharmacy->id|escape:'html'}">
    <input type="hidden" name="process" value="{$PROCESS|escape:'html'}">
</form>

{literal}
<script language="javascript">
function submit_pharmacy()
{
    if(document.pharmacy.name.value.length>0)
    {
        top.restoreSession();
        document.pharmacy.submit();
        //Z&H Removed redirection
    }
    else
    {
        document.pharmacy.name.style.backgroundColor="red";
        document.pharmacy.name.focus();
    }
}

 function Waittoredirect(delaymsec) {
     var st = new Date();
     var et = null;
     do {
     et = new Date();
     } while ((et - st) < delaymsec);
 }
</script>
{/literal}
